
package View;

import Module.addUserRoles;
import Module.User;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

/**
 *
 * @author CCD gruppe 2
 */
public class TeamInfoPanel extends JPanel {

    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField teamNameTextField;
    private javax.swing.JButton deleteTeamButton;
    private javax.swing.JList teamMembersList;
    private javax.swing.JCheckBox fasilitatorCheckBox;
    private javax.swing.JCheckBox customerCheckBox;
    private javax.swing.JCheckBox secretaryCheckBox;
    private DefaultListModel teamMemberListModel;
    private ArrayList<addUserRoles> userRoles = new ArrayList<addUserRoles>();
    private ArrayList<User> users = new ArrayList<User>();
    private String selectedUser;
    private int teamId;




    public TeamInfoPanel(){
        initComponents();
    }


    public void initComponents(){


        teamMembersList = new javax.swing.JList();
        teamMemberListModel = new DefaultListModel();
        teamMembersList.setModel(teamMemberListModel);
        jScrollPane2 = new javax.swing.JScrollPane();
        teamNameTextField = new javax.swing.JTextField();
        deleteTeamButton = new javax.swing.JButton();
        jScrollPane2.setViewportView(teamMembersList);
        secretaryCheckBox = new javax.swing.JCheckBox();
        fasilitatorCheckBox = new javax.swing.JCheckBox();
        customerCheckBox = new javax.swing.JCheckBox();
        teamNameTextField.setText("Team Navn");

        deleteTeamButton.setText("Slett Team");

        fasilitatorCheckBox.setText("Fasilitator");

        secretaryCheckBox.setText("Sekretær");

        customerCheckBox.setText("Kunde");


        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, teamNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(fasilitatorCheckBox)
                            .add(secretaryCheckBox)
                            .add(customerCheckBox)))
                    .add(deleteTeamButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 159, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(teamNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(fasilitatorCheckBox)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(secretaryCheckBox)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(customerCheckBox))
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE))
                .add(9, 9, 9)
                .add(deleteTeamButton))
        );
        fasilitatorCheckBox.setVisible(false);
        secretaryCheckBox.setVisible(false);
        customerCheckBox.setVisible(false);
    }

    public JButton getDeleteTeamButton() {
        return deleteTeamButton;
    }

    public JScrollPane getjScrollPane2() {
        return jScrollPane2;
    }

    public DefaultListModel getTeamMemberListModel() {
        return teamMemberListModel;
    }

    public JList getTeamMembersList() {
        return teamMembersList;
    }

    public JTextField getTeamNameTextField() {
        return teamNameTextField;
    }

    public JCheckBox getCustomerCheckBox() {
        return customerCheckBox;
    }

    public JCheckBox getFasilitatorCheckBox() {
        return fasilitatorCheckBox;
    }

    public JCheckBox getSecretaryCheckBox() {
        return secretaryCheckBox;
    }
    public ArrayList<addUserRoles> getUserRoles() {
        return userRoles;
    }

    public void setUserRoles(ArrayList<addUserRoles> userRoles) {
        this.userRoles = userRoles;
    }

    public String getSelectedUser() {
        return selectedUser;
    }

    public void setSelectedUser(String selectedUser) {
        this.selectedUser = selectedUser;
    }
    /*
     * This methods takes inn a String that contains the username
     * return the index of this username in userRoles
     */
    public int getIndexUserRoles(String u){
        for(int i=0;i<userRoles.size();i++){
            if(userRoles.get(i).getUser().getFullname().equals(u)){
                return i;
            }
        }
        return -1;
    }

    public ArrayList<User> getUsers() {
        return users;
    }

    public void setUsers(ArrayList<User> users) {
        this.users = users;
    }

    public int getTeamId() {
        return teamId;
    }

    public void setTeamId(int teamId) {
        this.teamId = teamId;
    }



}
